package backend.importexport.controller;

import util.database.index.CreateIndex;
import com.opensymphony.xwork2.ActionSupport;

import dbinit.csv.ImportBasicProfile;
import dbinit.csv.ImportCategory;
import dbinit.csv.ImportProductCsv;
import dbinit.csv.ImportProductSearch;



public class ProfileAction extends ActionSupport
{
	
	private static final long serialVersionUID = 12342345L;
	String Filename;
	String parameterName=null;
	public String execute() throws Exception{
		//DbUtil.reCreateDb("advprop");
		this.Filename=this.getFilename();
		this.parameterName=this.getParameterName();
		if ("Profile Import".equals(this.parameterName))
		{
			ImportBasicProfile.doImport(this.Filename);
		}
		else if ("Properties Import".equals(this.parameterName))
		{
			ImportProductCsv.doImport(this.Filename);
			CreateIndex crtIdx = CreateIndex.getInstance();
			crtIdx.doProductSearchIndex();
		}
		else if ("Category Import".equals(this.parameterName))
		{
			ImportCategory.doImport(this.Filename);
		}
		else 
		{
			ImportProductSearch.doImport(this.Filename);
		}
		return SUCCESS;
		
		
		
		
		
		
		
	}
	public String getParameterName() {
		return parameterName;
	}
	public void setParameterName(String parameterName) {
		this.parameterName = parameterName;
	}
	public String getFilename() {
		return Filename;
	}
	public void setFilename(String filename) {
		Filename = filename;
	}
	

}
